package com.microtf.inscription.framework.autoconfigure;

import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;

import java.util.concurrent.TimeUnit;

/**
 * framework全局使用的http请求客户端
 * @version 1.0
 * @since 1.0
 * @author guliuzhong
 */
@ConditionalOnClass({OkHttpClient.class})
@Slf4j
public class NetClientAutoConfiguration {
    /**
     * http客户端
     *
     * @return OkHttpClient
     */
    @Bean
    OkHttpClient okHttpClient() {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        builder.connectTimeout(30, TimeUnit.SECONDS);
        log.info("regisgter NetClient okhttp version default timeout{}",30);
        return builder.build();
    }
}
